from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
# service = ChromeService(executable_path='chromedriver.exe')
service = ChromeService(executable_path='chromedriver.exe')
driver = webdriver.Chrome(service=service)
url = 'https://www.baidu.com'
driver.get(url)
# 通过id属性获取对象
# button = driver.find_element(by=By.ID,value='su')
# print(button)
# 通过name获取对象
# button = driver.find_element(by=By.NAME,value='wd')
# print(button)
# 通过xpath 获取对象
# button = driver.find_element(by=By.XPATH,value='//input[@id="su"]')
# print(button)
# 通过标签名字获取对象
# button = driver.find_element(by=By.TAG_NAME,value='input')
# print(button)
# 通过bs4语法获取对象
# button = driver.find_element(by=By.CSS_SELECTOR,value='#su')
# print(button)
# 获取连接对象
button = driver.find_element(by=By.LINK_TEXT,value='新闻')
print(button)